package com.hc.window.settingView;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

import com.hc.bean.Dot;

public class CachePathData {
	private ConcurrentHashMap<Integer, List<Dot>> pathMap = new ConcurrentHashMap<Integer, List<Dot>>();
	private static CachePathData data = null;
	private CachePathData(){
		
	}
	
	public static synchronized CachePathData getInstance(){
		if(data == null){
			data = new CachePathData();
		}
		return data;
	}
	
	public void add(int id, int x, int y){
		if(pathMap.containsKey(id)){
			pathMap.get(id).add(new Dot(x, y));
		}else{
			List<Dot> list = new ArrayList<Dot>();
			list.add(new Dot(x, y));
			pathMap.put(id, list);
		}
	}

	public ConcurrentHashMap<Integer, List<Dot>> getPathMap() {
		return pathMap;
	}
	
	public void clear(){
		pathMap.clear();
	}
	
	public void clearPathDataById(int id){
		if(pathMap.containsKey(id)){
			pathMap.remove(id);
		}
	}
}
